﻿
@{
    ViewBag.Title = "住院统计报表";
    Layout = "~/Views/Shared/_Index.cshtml";
}


<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>
                <th class="formTitle">开始时间：</th>
                <td class="formValue">
                    <input id="ksrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:140px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss', onpicked: function () { refReport(); } })"
                           value="@DateTime.Now.ToString("yyyy-MM-01 00:00:00")" />
                </td>
                <th class="formTitle">结束时间：</th>
                <td class="formValue">
                    <input id="jsrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:140px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd  HH:mm:ss' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd  HH:mm:ss', onpicked: function () { refReport(); } })"
                           value="@DateTime.Now.ToString("yyyy-MM-dd  23:59:59")" />
                </td>
                <th class="formTitle"></th>
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <th></th>
                <td></td>
                <th></th>
                <td></td>
            </tr>
        </table>
    </div>
</div>
<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>
<script type="text/javascript">
    var reportServerHOST = '@(ViewBag.ReportServerHOST)';
    var orgId = '@(ViewBag.OrgId)';
    //$(function(){
    //    submit();
    //});

    function submit() {
        if ($('#ksrq').val().length == 0 || $('#jsrq').val().length == 0) {
            $.modalAlert("请选择时间范围", "error");
            return;
        }
        getFormatDate($('#ksrq').val());
        var url = reportServerHOST +'Pages/ReportViewer.aspx?/Newtouch.Report.MRMS/出院病人来源构成表(全院)&rs:Command=Render';
		//url += "&kssj=" + $('#ksrq').val() + "&jssj=" + $('#jsrq').val();
        url += "&OrganizeId=6d5752a7-234a-403e-aa1c-df8b45d3469f";
        url += "&begin=" + $('#ksrq').val();
        url += "&end=" + $('#jsrq').val();
		setTimeout("$.loading(true, '正在请求报表页面...');", 10);
        $("#iframerightiframerightiframerightttt").attr('src', url);
       
    }
    function getFormatDate(time) {
        debugger;
        var nowDate =  time;
        nowDate = new Date(nowDate.replace(/-/, "/"))
        console.log(nowDate);
        var year = nowDate.getFullYear();
        var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() +1) : nowDate.getMonth() +1;
        var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
        // var hour = nowDate.getHours()< 10 ? "0" + nowDate.getHours() : nowDate.getHours();    
        // var minute = nowDate.getMinutes()< 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();    
        // var second = nowDate.getSeconds()< 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();    
        return year + "-" + month + "-" + date;
    }
  
    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55
        $('#layout iframe').css('height', h);

    });

    //刷新列表
    function refReport() {
        $("#btn_search").trigger('click');
    }

</script>
